// 防抖：事件触发后n秒之后执行， 如果n秒内有触发就重新计时

function debounce(fn, delay) {
    let timer;

    return function() {
        let _this = this;
        let args = arguments;
        if (timer) {
            clearTimeout(timer);
        };
        timer = setTimeout(function() {
            fn.apply(_this, args);
            timer = null;
        }, delay);
    };
};